package com.wy.service.impl.sys;


import com.wy.constants.CommonConstants;
import com.wy.constants.CommonValues;
import com.wy.dao.SystemValuesMapper;
import com.wy.model.sys.SystemValues;
import com.wy.service.sys.SystemValuesService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service(value = "systemValuesServiceImpl")
public class SystemValuesServiceImpl implements SystemValuesService {
    @Autowired
    private SystemValuesMapper systemValuesMapper;

    @Autowired
    private CommonValues commonValues;

    @Override
    public void insert(SystemValues values) {
        systemValuesMapper.insert(values);
    }

    @Override
    public void del(int id) {
        systemValuesMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void delete(List<String> groupId) {
        systemValuesMapper.delete(groupId);
    }

    @Override
    public void update(SystemValues values) {
        systemValuesMapper.updateByPrimaryKey(values);
    }

    @Override
    public SystemValues selectByNameAndType(SystemValues values) {

        return  systemValuesMapper.selectByNameAndType(values);
    }

    @Override
    public List<SystemValues> listByType(String type,String path ,Integer residenceId) {
//        //获取图片类型的常量
//        List<SystemValues> valuesList = systemValuesMapper.listByType(type, CommonConstants.IMG,residenceId);
//        if(null == valuesList || valuesList.size() == 0) {
//            valuesList = systemValuesMapper.listByType(type,null,residenceId);
//        }else {
//            if(StringUtils.isEmpty(path)){
//                path = commonValues.getOutsidePath();
//            }
//            for(SystemValues systemValues : valuesList) {
//                systemValues.setValue(path + systemValues.getValue());
//            }
//        }

        //获取图片类型的常量
        List<SystemValues> valuesList = systemValuesMapper.listByType(type, null,residenceId);
        return valuesList;
    }

    @Override
    public List<SystemValues> listAll() {

        return  systemValuesMapper.listAll();
    }
}
